<?php

namespace app\common\model;


use app\common\core\BaseModel;

class AuthGroupAccess extends BaseModel
{
    protected $name = 'auth_group_access';
    public function group($is_menu=false)
    {
        $res = AuthGroup::where('id',$this->group_id)
            ->column('rules');
        $resAll = [];
        foreach ($res as $k=>$v){
            $tem = explode(',',$v);
            if(in_array('*',$tem)){
                if($is_menu){
                    return AuthRule::where('status',1)
                        ->where('ismenu',1)
                        ->column('id');
                }else{
                    return AuthRule::where('status',1)
                        ->column('id');
                }
            }else{
                $resAll = array_merge($resAll,$tem);
            }
        }
        return AuthRule::where('id','in',$resAll)
            ->where('status',1)
            ->column('id');

    }
}